import Case_BluePrint
import urllib


url = "http://www.canlii.ca/en/ab/abca/doc/1970/1970altascad1/1970altascad1.html"

assualt_count = 0
consent_count = 0
homicide_count = 0
culpable_homicide_count = 0
murder_count = 0
manslaughter_count = 0
sexual_assault_count = 0
cruelty_to_animal_count = 0
criminal_negligence_count = 0
hate_crime_count = 0


def case_parser(address_list):
    '''Looks for stuff in each case'''
    
    casetype = "non-criminal"
    '''for address in address_list:'''
    webpage = urllib.urlopen(url)
    for eachLine in webpage:
        eachLine.strip()
        '''find case type'''
        if "R. v. " in eachLine:
            casetype = "criminal"
            
        '''find judges'''
        if "The Honourable" in eachLine:
            judge = eachLine
            judge = judge.replace('<P class="Bench">', "")
            judge = judge.replace('</P>',"")
            
        '''find case name'''
        if '<meta name="DC.Title"' in eachLine:
            title = eachLine
            title = title.replace('<meta name="DC.Title" content="', "")
            title = title.replace('"/>',"")
        '''find category of court'''
        
        '''find name of individual parties'''
        
        '''find date'''
        if '<meta name="DC.Date"' in eachLine:
            date = eachLine
            date = date.replace('<meta name="DC.Date" content="',"")
            date = date.replace('"/>', "")
            
        '''find Registry'''
        if '<P class="Metadata"><B>Registry: </B>' in eachLine:
            registry = eachLine
            registry = registry.replace('<P class="Metadata"><B>Registry: </B>',"")
            registry = registry.replace('</P>',"")
            
        '''find Counsel'''
        
        '''Find Docket'''
        
        '''Find URL'''
        if '<td class="label">URL:</td><td class="documentStaticUrl">' in eachLine:
            URL = eachLine
            URL = URL.replace('<td class="label">URL:</td><td class="documentStaticUrl">',"")
            URL = URL.replace('</td></tr>',"")
        
    '''word count'''
    word_count(web_page)
    
def word_count(eachLine):
    '''counts words in eachLine'''
    eachLine = eachLine.strip('/n')
    if 'assault' in eachLine or 'Assault' in eachLine:
        assault_count = assault_count + eachLine.count('assault')
        assault_count = assault_count + eachLine.count('Assault')
    if 'consent' in eachLine or 'Consent' in eachLine:
        consent_count = consent_count + eachLine.count('consent')
        consent_count = consent_count + eachLine.count('Consent')
    if 'homicide' in eachLine or 'Homicide' in eachLine:
        homicide_count = homicide_count + eachLine.count('homicide')
        homicide_count = homicide_count + eachLine.count('Homicide')
    if 'culpable homicide' in eachLine:
        culpable_homicide_count = culpable_homicide_count + eachLine.count('culpable homicide')
    if 'murder' in eachLine or 'Murder' in eachLine:
        murder_count = murder_count + eachLine.count('murder')
        murder_count = murder_count + eachLine.count('Murder')
    if 'manslaughter' in eachLine or 'Manslaughter' in eachLine:
        manslaughter_count = manslaughter_count + eachLine.count('manslaughter')
        manslaughter_count = manslaughter_count + eachLine.count('Manslaughter')
    if 'Sexual assault' in eachLine or 'sexual assault' in eachLine:
        sexual_assault_count += eachLine.count('Sexual_assualt')
        sexual_assault_count += eachLine.count('sexual_assault')
    if 'cruelty to animal' in eachLine:
        cruelty_to_animal_count += eachLine.count('cruelty to animal')
    if 'criminal negligence' in eachLine:
        criminal_negligence_count += eachLine.count('criminal negligence')
    if 'hate crime' in eachLine:
        hate_crime_count += eachLine.count('hate crime')
        
            
if __name__ == "__main__":
    case_parser("blah")
